<template>
  <div>
    <van-nav-bar
      :title="commlist.reply_count? commlist.reply_count+'条回复':'暂无回复'"
      @click-left="$emit('click-left')"
    >
      <template #left>
        <van-icon name="cross" />
      </template>
    </van-nav-bar>
    <div class="gunDongTiao">
      <commentltem :comment='commlist'/>
      <van-cell title="全部回复"/>
      <CommwntList type="c" :source="commlist.com_id+''" :list="list"/>
    </div>
    <div class="post-warp">
      <van-button @click="isShowPostRepCommentPopup=true" round>评论</van-button>
    </div>

    <van-popup v-model="isShowPostRepCommentPopup" position="bottom">
        <CommentPost @on_success="onSuccess" :target="commlist.com_id" :artId="$route.params.artId"/>
    </van-popup>
  </div>
</template>

<script>
import commentltem from '@/components/commentltem'
import CommwntList from './CommwntList.vue'
import CommentPost from './CommentPost.vue'
export default {
  components: {
    commentltem,
    CommwntList,
    CommentPost
  },
  props: {
    commlist: {
      type: Object,
      require: true
    }
  },
  data () {
    return {
      list: [],
      isShowPostRepCommentPopup: false
    }
  },

  created () {

  },

  methods: {
    onSuccess (e) {
      this.isShowPostRepCommentPopup = false
      this.list.unshift(e)
      this.commlist.reply_count++
    }
  }
}
</script>

<style scoped lang='less'>
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hotpink;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.gunDongTiao {
  position: absolute;
  width: 100%;
  top: 92px;
  bottom: 100px;
  overflow-y: scroll;
}
</style>
